<template>
	<div style="margin-top:50px;">	 
		<TopWithBack></TopWithBack>
    <div class="updatepassword_box">
        <input type="tel" id="phone" placeholder="请输入您的手机号" value="" v-model="loginForm.account" />
    </div>
    <div class="index_divide"></div>
    <!-- <div class="updatepassword_idetity_box">
            <input type="text" id="phoneverify" name="phoneverify" placeholder="请输入输入验证码" />
            <button type="button" id="sendvf" >发送验证码</button>
        </div> -->
    <!-- <div class="index_divide"></div> -->
    <div class="updatepassword_box">
        <input type="password" name="pwdtwo" id="pwdtwo" placeholder="请输入您的密码" v-model='loginForm.password'/>
    </div>
    <div class="index_divide"></div>
    <div class="update_btn" @click="handleLogin">
        <input type="submit" value="登陆">
    </div>
    <div class="find_password_box">
        <div @click="Findpassword">找回密码</div>
        <div @click="Register">注册新账号</div>
    </div>
  </div>
</template>
<script>
import TopWithBack from './../common/TopWithBack.vue'
import { login } from '@/api/login'
export default{
  name: 'Login',
  data(){
  	return{
      loginForm:{
        account:'',//账号
        password:''//密码
      }        
  	}
  },
  methods:{
    //登录前验证
    handleLogin:function(){
        var account=this.loginForm.account
          // console.log(account)
        var password=this.loginForm.password
        if(account==''){
            this.$vux.toast.show({
              text: '账号不能为空',
              type: 'warn',
              time: 800,
            })
            return
        }
        if(password==''){
            this.$vux.toast.show({
              text: '密码不能为空',
              type: 'warn',
              time: 800,
            })
            return
        }
        this.dologin();

    },
    //登录操作
    dologin(){
        // console.log('1')
        this.$vux.loading.show({ text: 'Loading' })
        this.$store.dispatch('Login', this.loginForm).then(() => {
            // console.log('1')
            this.$vux.loading.hide()
            this.$router.push({ path: this.redirect || '/' })
          }).catch((err) => {
            console.log(err)
          })
    },
    //找回密码
    Findpassword(){
      this.$router.push({
        name:'FindPassword'
      })
    },
    //注册
    Register(){
      this.$router.push({
        name:'Register'
      })
    },  
  },
  components:{
  	TopWithBack,
  }
}
</script>
<style>
.home{
  font-size:50px;
}
</style>


